package com.zj.study.strategy1;

import com.baomidou.mybatisplus.annotation.EnumValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author 赵赳
 * @since 2022/7/26 16:01
 */
@Getter
@AllArgsConstructor
public enum PaymentEnum {

  ALIPAY(1, "支付宝"),
  WECHATPAY(1, "支付宝");

  @EnumValue
  private final Integer code;

  private final String desc;

  /**
   * 转换数字为枚举
   *
   * @param code 数值
   * @return 对应支付枚举
   */
  public static PaymentEnum transferNum(Integer code) {
    switch (code) {
      case 1:
        return ALIPAY;
      case 2:
        return WECHATPAY;
    }
    throw new RuntimeException("支付方式错误");
  }

}
